
import socket,time

def server_thread(local_addr):
    udp_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    udp_socket.bind(local_addr)
    print("start listen:{}".format(local_addr))
    while True:
        recv_data, addr = udp_socket.recvfrom(1024)  # 1024表示本次接收的最大字节数
        print("recv:{}:{}".format(addr,recv_data))
        udp_socket.sendto("hello!".encode('utf-8'),addr)
    
    udp_socket.close()
        


local_addr = ('127.0.0.1', 12344) 
server_thread(local_addr)

    

